import numpy
import numpy as np
from utils import *
import argparse


def identify_high_stochastic_var(trajectories, args):
    '''
    发现一些具有高度随机的变量（作为Parent备选）
    :param data:
    :return:
    '''

    # 获得变量个数
    var_num = trajectories.shape[-1]
    openList = []
    delta = 0.1
    # 获取parents
    parent_set = None
    for i in range(var_num):
        args.i = i
        data = np.concatenate((trajectories[:, :, i].reshape((args.L, args.h, 1)), obs), axis=2)
        # 估计P(Oi, Pa(Oi)):
        joint_prob = cal_joint_prob
        # 估计P(pa(Oi))
        marginal_prob = cal_marginal_pro
        # 计算条件熵 H(Oi|Pa(Oi))
        condition_entropy = cal_condition_entropy(marginal_prob, joint_prob, parent_set, args)
        if condition_entropy > delta:
            openList.append(i)
    return openList


def search_causes(openList, trajectories):
    var_num = trajectories.shape[-1]

    while len(openList) != 0:
        X = openList.pop()
        while True:
            max_gain = 0
            for i in range(var_num):
                pass


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--h', type=int, default=100, help="每一条轨迹的时间步数")
    parser.add_argument('--L', type=int, default=100, help="多少条轨迹")
    parser.add_argument('--alpha', type=int, default=1, help="normalization")
    parser.add_argument('--w', type=int, default=0.3, help="带宽")
    args = parser.parse_args()
